<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5 Transitional//EN">
<%@ page pageEncoding="UTF-8" %>
<%@ page import="jp.co.technotree.apl.api.common.Message,jp.co.technotree.common.ApplicationManager" %>
<%@page import="jp.co.technotree.apl.api.common.FwCom"%>
<%@page import="jp.co.technotree.apl.cmd.rental.Ren3000Bean"%>
<jsp:useBean id="formBean" class="jp.co.technotree.apl.cmd.rental.Ren3000Bean" scope="request" />
<%
	ApplicationManager appMng = ApplicationManager.getInstance();	//アプリケーションマネージャの取得（パス等）

%>
<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel='stylesheet' type='text/css' href='../../common/css/rental/ren3000.css' >
<link rel='stylesheet' type='text/css' href='../../common/css/popUp.css' >

<script type='text/javascript' src='../../common/js/popUp.js'></script>
<script type='text/javascript' src='../../common/js/NumKeyBoard4.js'></script>


<style type="text/css">

	.mainTbl_Left{
		 border: 0px solid #CCCCFF;
		 height:150px;
		 width: 210px;
		 margin-top:-250px;
		 align:center;
	}

	.mainTbl_Right{
		 border: 0px solid #CCCCFF;
		 height:580px;

	}


	.confirmBtn {
		width: 80px;
		height:40px;
		font-size:18px;
	}

	.itemSearch {
		width: 130px;
		height:30px;
		font-size:18px;
		margin-top:1px;
		background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
		color: #fff;
		font-weight:bold;
		text-shadow: -1px 2px rgba(0,0,0,0.2);
		-webkit-border-radius:10px;
	
		position:relative; z-index:1;
	}

	.confirmBtn2 {
		width: 120px;
		height:40px;
		font-size:18px;
	}


	.confirmBtn3 {
		width: 170px;
		height:40px;
		font-size:18px;
	}

	.selTitle{
	 font-size:16px;
	 valign:middle;

	}

	.ImageZone{
	 position:absolute;
	 top :80px;
	 right:150px;
	 visibility: visible;

	 width: 200px;
	 height:200px;
	}



	.OrderReason{
	 position:absolute;
	 top :100px;
	 left:660px;
	 visibility: visible;

	 width: 300px;
	 height:200px;
	}


.rePayTitle1{
	 position:absolute;
	 bottom :310px;
	 left:590px;
	 visibility: visible;

	 font-size:11px;
	 width: 100px;
	 height:10px;

	}

.rePayTitle2{
	 position:absolute;
	 bottom :310px;
	 left:791px;
	 visibility: visible;

	 font-size:11px;
	 width: 100px;
	 height:10px;

	}

	.warehouse{
	 position:absolute;
	 bottom :195px;
	 left:30px;
	 visibility: visible;

	 width: 930px;
	 height:190px;

	}

	.backBtn{
		width: 80px;
		height:50px;
		font-size:18px;
		margin-top:1px;
		background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
		color: #fff;
		font-weight:bold;
		text-shadow: -1px 2px rgba(0,0,0,0.2);
		-webkit-border-radius:10px;

		position:relative; z-index:1;
	}

	.orderBtn{
	width: 130px;
	height:50px;
	font-size:18px;
	margin-top:1px;
	background-image: -webkit-gradient(linear, left top, left bottom, from(#6699CC), to(#6699CC),color-stop(0.7,#6688CC));
	color: #fff;
	font-weight:bold;
	text-shadow: -1px 2px rgba(0,0,0,0.2);
	-webkit-border-radius:10px;

	position:relative; z-index:1;
}



	img {
	     max-height:237px;
	     max-width:330px;
	     height :auto;
	     width :auto;
	    } 

</style>



<script language='javascript'>

//画面固定
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

var clsNKB = new CNumKeyBoard();

function onInit(){

	//返却登録完了後、メッセーを出してメイン画面に遷移
	var stateFlg = "<%=formBean.getStateFlg()%>";
	
	var afterFunc="nextPageJump('ren1000');"
	
	if(stateFlg == "back"){
		//返却登録処理を正常に完了しました
		alert_Info2("<%=Message.getMessage("INF00020").replace("$1", "返却登録処理")%>",afterFunc);
	}else if(stateFlg == "cancelBack"){
		
		//出庫取消
		//出庫取消を正常に完了しました
		alert_Info2("<%=Message.getMessage("INF00020").replace("$1", "出庫取消")%>",afterFunc);
	}
	
	//---------------------------------------------
	
	
	
	//-------------------------------------------------------------------------
	//<!-- NumKeyBoard START -->
	ProcStart	= new Date();

	clsNKB.init("NumKeyBoardID");
//	clsNKB.parentElement	= document.getElementById("BodyBlock");

	clsNKB.textFontSize		= 20;
	clsNKB.buttonFontSize	= 30;
	clsNKB.boxX				= -130;
	clsNKB.boxY				= 300;
	clsNKB.boxBalloonOffset	= 210;
	//<!-- NumKeyBoard END -->
	//-------------------------------------------------------------------------
	
	//返却チェック者
	//確定時にログインユーザコードをデフォルト値せセット
	selectedChange("usrList","<%=formBean.getRetUsr()%>");
	odrUsrSideDell2(document.getElementById("usrList"));
	
}

function selectedChange(formSelectId, itemValue){
	var objSelect = document.getElementById(formSelectId);
	var m = objSelect.length;
	var i = 0;

	for(i=0;m>i;i++){
		var arr = objSelect.options[i].value.split("*");
		if(arr[1] == itemValue){
			objSelect.options[i].selected = true;
			break;
		}
	}
}




function nextPageJump(nextPage){
	mainForm = document.getElementById("F1");
	document.getElementById("nextPage").value = nextPage;
	mainForm.submit();
}



//=======================================================select変更連動
//===========================================
//組がが変更された時の処理
//===========================================
//子ノード作成
function selectIn(obj,arrVar,arrTxt){
	var strObject = document.getElementById(obj);
	for(var k=0; k < arrVar.length; k++){
		//optionのvalue属性にセット(key)
		var ele = document.createElement("option");
		ele.value = arrVar[k];
		//optionにセット(value)
		var str = document.createTextNode(arrTxt[k]);
		ele.appendChild(str);

		strObject.appendChild(ele);
	}
}


//子ノード削除
function selectDel(Obj){
	var strObject = document.getElementById(Obj);
	for(var i= strObject.childNodes.length-1; i >= 0;i--) {
		strObject.removeChild(strObject.childNodes[i]);
	}
}


function reformWork(){
	var strWorkCd1Txt= new Array();
	var strWorkNm1Val= new Array();

	var strWorkCd1Txt2= new Array();
	var strWorkNm1Val2= new Array();

	strWorkCd1Txt[0] = "";
	strWorkNm1Val[0] = "";

	strWorkCd1Txt2[0] = "";
	strWorkNm1Val2[0] = "";

	 //=======================================
	 //組リスト取得
	 //=======================================
	 <%
	 Ren3000Bean.PullData[] work1NmPullList =formBean.getInputEmpPullList();

	 for (int j=0; j < work1NmPullList.length; j++){
		 Ren3000Bean.PullData  data = work1NmPullList[j];
	%>
		strWorkCd1Txt[<%=j+1%>] = "<%=data.value%>"
	 	strWorkNm1Val[<%=j+1%>] = "<%=data.key%>"
	<%}%>
	   //作業内容の子ノードを削除
	   selectDel("odrUsr");
	   //子ノードを作成
	   selectIn("odrUsr",strWorkNm1Val,strWorkCd1Txt);


	 //=======================================
	 //発注担当リスト取得
	 //=======================================
	 <%
	 Ren3000Bean.PullData[] work2NmPullList =formBean.getInputEmpPullList2();

	 for (int j=0; j < work2NmPullList.length; j++){
		 Ren3000Bean.PullData  data = work2NmPullList[j];
	 %>
		strWorkCd1Txt2[<%=j+1%>] = "<%=data.value%>"
	 	strWorkNm1Val2[<%=j+1%>] = "<%=data.key +"*"+ data.key2%>"
	<%}%>
	   //作業内容の子ノードを削除
	   selectDel("usrList");
	   //子ノードを作成
	   selectIn("usrList",strWorkNm1Val2, strWorkCd1Txt2);


}



//組の区分選択により
function odrUsrSideDell(odrUsr){
	var strWorkCd1Txt= new Array();
	var strWorkNm1Val= new Array();
	var arrCnt=1;
	strWorkCd1Txt[0] = "";
	strWorkNm1Val[0] = "";

	//発注担当者の子ノードを削除
	selectDel("usrList");

	 <%
		 Ren3000Bean.PullData[] work1ForWork2List =formBean.getInputEmpPullList2();
		 for (int j=0; j < work1ForWork2List.length; j++){
			 Ren3000Bean.PullData  data = work1ForWork2List[j];
	 %>
		 	if(odrUsr.value == "<%=data.key%>"){
		 		strWorkCd1Txt[arrCnt] = "<%=data.value%>"
			 	strWorkNm1Val[arrCnt] = "<%=data.key  +"*"+ data.key2%>"
			 	arrCnt++;
			//組の区分が何も選択ない場合
		 	}else if(odrUsr.value == ""){
		  		reformWork();
		 		return;
		 	}
	 <%}%>


//子ノードを作成
selectIn("usrList",strWorkNm1Val,strWorkCd1Txt);



}


//担当者の区分選択により
function odrUsrSideDell2(usrList){
	var strWorkCd1Txt= new Array();
	var strWorkNm1Val= new Array();
	var arrCnt=1;
	strWorkCd1Txt[0] = "";
	strWorkNm1Val[0] = "";

	//key1とkey2を分ける
	var usrListArr = usrList.value.split("*");


	//発注担当者の子ノードを削除
	selectDel("odrUsr");

	 <%
		 Ren3000Bean.PullData[] work1ForWorkList =formBean.getInputEmpPullList();
		 for (int j=0; j < work1ForWorkList.length; j++){
			 Ren3000Bean.PullData  data = work1ForWorkList[j];
	 %>
		 	if(usrListArr[0] == "<%=data.key%>"){
		 		strWorkCd1Txt[arrCnt] = "<%=data.value%>"
			 	strWorkNm1Val[arrCnt] = "<%=data.key%>"

			 	arrCnt++;
			//組の区分が何も選択ない場合
		 	}else if(usrList.value == ""){
		  		reformWork();
		 		return;
		 	}
	 <%}%>


//子ノードを作成
selectIn("odrUsr",strWorkNm1Val,strWorkCd1Txt);

//発注担当者による組の自動選択
document.getElementById("odrUsr").selectedIndex = 1;

}

//=======================================================select変更連動





//=================================================================
//	データ入力後の処理（使用数量）
//=================================================================
function afterInputData(obj) {
	//０の場合
//	if(obj.value ==0){
//		alert_Custom("<%=Message.getMessage("WRN00060").replace("$1", "数量")%>");   //RN00060=$1には０以上の数値を入力して下さい。
//		return ;
//	}

}
//--------------------------------
//カンマ削除関数
//--------------------------------
function delComma(w) {
  var z = w.replace(/,/g,"");
  return (z);
}

//--------------------------------
//	型変換 String→Numeric
//--------------------------------
function convStrToNum(strVal) {
	var cnv = Number(strVal);
	var res = 0;
	if(isNaN(cnv)) {
		// 数値じゃない!
	} else {
		res = cnv;
	}
	return res;
}
//<!-- NumKeyBoard END -->
//----------------------------------------------------------------------



//パップアップ解除
function back(){
	
	document.getElementById("orderExe").value = "";
	
	document.getElementById("opAlertBtn").style.display = "none";
	document.getElementById("opAlert").style.display = "none";
	document.getElementById("opAlertButton").style.display = "none";
	document.getElementById("opAlertTop").style.display = "none";
	document.getElementById("allbackgr").style.display = "none";
}


//入荷取消ボタンの押下
function cancelBtn(){
	
	//予備品修理貸出出庫Ｔの更新日を比較
	 updateDtCheck("1");
}



//入荷取消ボタンの押下
function backBtn(){
	
	var afterFunc="nextPageJump('ren1000');"
		
	//返却登録を中止します。よろしいですか？
	if ("undefind"!=confirm_Custom3("<%=Message.getMessage("INF01040").replace("$1", "返却登録処理")%>",afterFunc)){
		return;
	}

}


//入荷取消の実行
function cancelBtnExe(){
	
	mainForm = document.getElementById("F1");

	var usrListKey = document.getElementById("usrListKey");				//返却チェック者 キー
	var usrListObj = document.getElementById("usrList");				//返却チェック者
	var usrListArr = usrListObj.options[usrListObj.selectedIndex].value.split("*");

	if(usrListArr[1]){
		usrListKey.value = usrListArr[1];
	}

	
	document.getElementById("orderExe").value = "2";
	
	//出庫をキャンセルします。よろしいですか？
	if ("undefind"!=confirm_Custom("<%=Message.getMessage("INF01051").replace("$1", "出庫")%>")){
		return;
	}
	
	mainForm.submit();
}



//「発注」ボタン押下
function orderBtn(){


	//予備品修理貸出出庫Ｔの更新日を比較
	 updateDtCheck("0");

}




//入力チェックによる背景色を付ける
function validCheck(){
	
	var odrUsrObj = document.getElementById("odrUsr");						//完了担当者(組)
	var usrListObj = document.getElementById("usrList");				   //完了担当者
	var usrList = usrListObj.options[usrListObj.selectedIndex];
	
	
	var retSiteObj = document.getElementById("retSite");					//返却先
	var retSiteList  = retSiteObj.options[retSiteObj.selectedIndex];
	
	var scrSiteObj = document.getElementById("scrSite");				    //廃棄先
	var scrSiteList = scrSiteObj.options[scrSiteObj.selectedIndex];
	
	
   var retNewNum = document.getElementById("retNewNum");		//出庫新品数量(予備品修理貸出返却Ｔ)_返却先
   var retUsedNum = document.getElementById("retUsedNum");		//出庫中古数量(予備品修理貸出返却Ｔ)_返却先
   
   
   var scrNewNum = document.getElementById("scrNewNum");		//廃棄新品数量(予備品修理貸出返却Ｔ)_廃棄先
   var scrUsedNum = document.getElementById("scrUsedNum");		//廃棄中古数量(予備品修理貸出返却Ｔ)_廃棄先
   
   
	//============
	 //背景色付ける
	 //============
	 if(retDt.value==""){
		 retDt.style.backgroundColor = 'pink';
     }
	 if(usrList.value==""){
		 usrListObj.style.backgroundColor = 'pink';
		 odrUsrObj.style.backgroundColor = 'pink';
	 }
//	 if(retSiteList.value=="" && (retNewNum!="" || retUsedNum!="")){
//		 retSiteObj.style.backgroundColor = 'pink';
//    }
//	 if(scrSiteList.value=="" && (scrNewNum!="" || scrUsedNum!="")){
//		 scrSiteObj.style.backgroundColor = 'pink';
//     }
	 
	 
	 //============
	 //背景色解除
	 //============
	 if(retDt.value!=""){
		 retDt.style.backgroundColor = 'white';
	 }
	 if(usrList.value!=""){
		 usrListObj.style.backgroundColor = 'white';
		 odrUsrObj.style.backgroundColor = 'white';
	 }
	 if(retSiteList.value!=""){
		 retSiteObj.style.backgroundColor = 'white';
	 }
	 if(scrSiteList.value!=""){
		 scrSiteObj.style.backgroundColor = 'white';
	 }
	 
	 
	 //新品数量、中古数量
	 retNewNum.style.backgroundColor = 'white';
	 retUsedNum.style.backgroundColor = 'white';
	 scrNewNum.style.backgroundColor = 'white';
	 scrUsedNum.style.backgroundColor = 'white';
	 
	 
}


//各数量マイナス値の場合チェック
function checkMinus(objDb,obj){
	var result= (Number(objDb) + Number(obj)).toString();

	if(result.indexOf("-") == 0){
		return true;
	}
	
	return false;
}




//「返却登録」ボタン押下
function orderBtnExe(){

		mainForm = document.getElementById("F1");

	   //----------------------------------------------
	   //画面の数量
	   var retNewNum = document.getElementById("retNewNum").value;			//出庫新品数量(予備品修理貸出返却Ｔ)_返却先
	   var retUsedNum = document.getElementById("retUsedNum").value;		//出庫中古数量(予備品修理貸出返却Ｔ)_返却先
	   
	   retNewNum = retNewNum.replace(",","");
	   retUsedNum = retUsedNum.replace(",","");
	   
	   
	   var scrNewNum = document.getElementById("scrNewNum").value;			//廃棄新品数量(予備品修理貸出返却Ｔ)_廃棄先
	   var scrUsedNum = document.getElementById("scrUsedNum").value;		//廃棄中古数量(予備品修理貸出返却Ｔ)_廃棄先
	   
	   scrNewNum = scrNewNum.replace(",","");
	   scrUsedNum = scrUsedNum.replace(",","");
	   
	  // alert(retNewNum+retUsedNum+scrNewNum+scrUsedNum);
	   
	   //DBの数量
	   var retNewNum_db="<%=formBean.getRetNewNum()%>";			    //出庫新品数量(予備品修理貸出返却Ｔ)
	   var retUsedNum_db="<%=formBean.getRetUsedNum()%>";			//出庫中古数量(予備品修理貸出返却Ｔ)
	   
	   var scrNewNum_db="<%=formBean.getScrNewNum()%>";			    //廃棄新品数量(予備品修理貸出返却Ｔ)
	   var scrUsedNum_db="<%=formBean.getScrUsedNum()%>";			//廃棄中古数量(予備品修理貸出返却Ｔ)
	   
	   

	   var inNumTotal = Number(retNewNum) + Number(retUsedNum) + Number(scrNewNum) + Number(scrUsedNum);   				 //画面の数量合計
	   var outNumTotal = Number(retNewNum_db) + Number(retUsedNum_db) + Number(scrNewNum_db) + Number(scrUsedNum_db);    //DBの数量合計
	   
	   var NumTotal = inNumTotal + outNumTotal; //全数量合計

	   var delvTotal = "<%=formBean.getDelvTotalNum() %>";
	   
	   
	   var delvDt =document.getElementById("delvDt").value;                 //出庫日
	   
	   if(delvDt!=""){
		   delvDt = delvDt.replace("/","-").replace("/","-");
	   }

	   var retDt =document.getElementById("retDt").value;                   //返却日
	   
	   var retSiteKey = document.getElementById("retSiteKey");              //返却先キー
	   var retSiteObj = document.getElementById("retSite");                 //返却先
	   retSiteKey.value = retSiteObj.options[retSiteObj.selectedIndex].value;

	   var scrSiteKey = document.getElementById("scrSiteKey");              //廃棄先キー
	   var scrSiteObj = document.getElementById("scrSite");                 //廃棄先
	   scrSiteKey.value = scrSiteObj.options[scrSiteObj.selectedIndex].value;
	   
	   
	   
		var usrListKey = document.getElementById("usrListKey");				//返却チェック者 キー
		var usrListObj = document.getElementById("usrList");				//返却チェック者
		var usrListArr = usrListObj.options[usrListObj.selectedIndex].value.split("*");

		if(usrListArr[1]){
			usrListKey.value = usrListArr[1];
			
		}else{
			usrListKey.value = "";
		}
		
		
		
		
		   
		   //==========================================================================
		   //返却先、廃棄先の入力チェックを数量（入力又はDB数）が入っているときのみでOK
		   var ret_check = false;
		   if(retNewNum != "" || retUsedNum != ""){
			   ret_check = true;
		   }
		   if(retNewNum_db != "0" || retUsedNum_db != "0"){
			   ret_check = true;
		   }
		   
		   
		   var scr_check = false;
		   if(scrNewNum != "" || scrUsedNum != ""){
			   scr_check = true;
		   }
		   if(scrNewNum_db != "0" || scrUsedNum_db != "0"){
			   scr_check = true;
		   }
		   
		   
		   //---------------------------------------------------------------------------
		
		
		
		validCheck();//入力チェックによる背景色を付ける
		
		//入力チェック
		if(usrListKey.value ==""){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "返却チェック者")%>");
			return ;
		}else if(retDt ==""){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "返却日")%>");
			return ;
		}else if(delvDt > retDt){
			alert_Custom("<%=Message.getMessage("WRN00040").replace("$1", "返却日").replace("$2", "出庫日")%>"); //返却日が出庫日より過去の日付です。
			return ;
		}else if(inNumTotal ==0){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "数量")%>");
			return ;
		}else if(inNumTotal ==0){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "数量")%>");
			return ;
		}else if(retSiteKey.value =="" && ret_check){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "返却先")%>");
			 retSiteObj.style.backgroundColor = 'pink';
			return ;
		}else if(scrSiteKey.value =="" && scr_check){
			alert_Custom("<%=Message.getMessage("WRN00010").replace("$1", "廃棄先")%>");
			scrSiteObj.style.backgroundColor = 'pink';
			return ;
		}else if(checkMinus(retNewNum_db, retNewNum)){
			alert_Custom("<%=Message.getMessage("WRN01540").replace("$1", "新規数量(在庫反映)").replace("$2", "新規数量(在庫反映)")%>");      //「新規数量が新規数量を超えています。
			return ;
		}else if(checkMinus(retUsedNum_db,retUsedNum)){
			alert_Custom("<%=Message.getMessage("WRN01540").replace("$1", "中古数量(在庫反映)").replace("$2", "中古数量(在庫反映)")%>");      //「中古数量が中古数量を超えています。
			return ;
		}else if(checkMinus(scrNewNum_db,scrNewNum)){
			alert_Custom("<%=Message.getMessage("WRN01540").replace("$1", "新規数量(在庫未反映)").replace("$2", "新規数量(在庫未反映)")%>");  //「新規数量が新規数量を超えています。
			return ;
		}else if(checkMinus(scrUsedNum_db,scrUsedNum)){
			alert_Custom("<%=Message.getMessage("WRN01540").replace("$1", "中古数量(在庫未反映)").replace("$2", "中古数量(在庫未反映)")%>");  //「中古数量が中古数量を超えています。
			return ;
		}else if(NumTotal > Number(delvTotal) || NumTotal < 0){
			alert_Custom("<%=Message.getMessage("WRN00050").replace("$1", "各返却数量及び廃棄数量の合計").replace("$2", "出庫数量")%>");      //各返却数量及び廃棄数量の合計が出庫数量を超えています。
			
			//======================================================================
			//数量が超えた場合Pピンク色を付ける
			if(retNewNum!=""){
				document.getElementById("retNewNum").style.backgroundColor = 'pink';
			}
			if(retUsedNum!=""){
				document.getElementById("retUsedNum").style.backgroundColor = 'pink';
			}
			if(scrNewNum!=""){
				document.getElementById("scrNewNum").style.backgroundColor = 'pink';
			}
			if(scrUsedNum!=""){
				document.getElementById("scrUsedNum").style.backgroundColor = 'pink';
			}
			//----------------------------------------------------------------------
			return ;
			
		}else{

			
			retSiteObj.style.backgroundColor = 'white';  //返却先色を白に
			scrSiteObj.style.backgroundColor = 'white';  //廃棄先色を白に
			
			document.getElementById("orderExe").value = "1";

			//予備のを返却をします。よろしいですか？
			if ("undefind"!=confirm_Custom("<%=Message.getMessage("INF01031").replace("$1", "予備品の返却")%>")){
				return;
			}
			mainForm.submit();

		}
}

//------------------------------------------------------------------------------




//出荷取消ボタン・返却登録のフラグ
var btnFlg="0";

//*************************************************
//AJAX 部分(//予備品修理貸出出庫Ｔの更新日を比較)
//*************************************************
function updateDtCheck(btn){

	if("1"==btn){
		btnFlg = "1";
	}else{
		
		btnFlg = "0";
	}
	
	var delvNo = document.getElementById("delvNo").value;

	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = checkStatus2;
	xmlHttp.open("GET","../ren3001/ren3001?delvNo="+delvNo,true);
	xmlHttp.send(null);

}

function checkStatus2(){
	if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
		var xml = xmlHttp.responseXML;
		var rootNodes = xml.getElementsByTagName("list");
		var rootNode = rootNodes[0];
		var json = JSONConvert(rootNode);
		if (json==null) {
		}else {
			var orderUpdateDt = json.updatedt;
			var confirmUdateDt = document.getElementById("updateDt").value;

			//更新日を比較
			if(orderUpdateDt == confirmUdateDt){

				if(btnFlg=="0"){
					orderBtnExe();   //発注実行
				}else{
					cancelBtnExe();  //取消実行
				}

			}else{
				
				//出荷取消ボタン・返却登録のフラグ分岐
				if(btnFlg=="0"){
					//var afterFunc="nextPageJump('ren1000');"
					alert_Custom("<%=Message.getMessage("WRN01102")%>");  //予備品の修理・貸出情報が既に変更されています。返却登録を再度やり直して下さい。
					return;
				}else{
					alert_Custom("<%=Message.getMessage("WRN01103")%>");  //予備品の修理・貸出出庫情報が既に変更されています。出庫キャンセルを再度やり直して下さい。
					return;
				}

			}

		}
	}
}



function JSONConvert(node){
	var type = node.nodeType;
	if ( isTextNode(node) ){
		var text = getTextValue(node);
		return text;
	}
	if ( type==1 ){
		var json = {};
		var nodeName = node.nodeName;
		var childs = node.childNodes;

		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			var obj = json[child.nodeName];

			if ( child.nodeType == 1 ){
				if ( obj ){
					var array = null;
					if ( !isArray(obj) ){
						array=[];
						array[array.length]=obj;
					}else{
						array=json[child.nodeName];
					}
					array[array.length]=JSONConvert(child);
					json[child.nodeName]=array;
				}else{
					json[child.nodeName]=JSONConvert(child);
				}
			}
		}
		return json;
	}
}

function isTextNode(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		for (var i = 0; i<childs.length; i++){
			var child = childs[i];
			if ( child.nodeType != 3 ) return false;
		}
	}
	return true;
}

function getTextValue(node){
	if ( node.hasChildNodes() ){
		var childs = node.childNodes;
		var child = childs[0];
		if ( child.nodeType == 3 ){
			return child.nodeValue;
		}
	}
	return null;
}

//------------------------------------------------------------------------------




</script>


</head>

<body onLoad="onInit()">
<form name="main" id="F1" action="./ren3000" method="post" class="frmMain">

<table style="">
	<!--HEADER TITLE START -->
	<tr style = "background-color:#e1e1e1;  font-weight: bold;  border-bottom:1px solid #e1e1e1; background: -webkit-gradient(linear, left top, left bottom, from(#e1e1e1), to(#ffffff));　 ">
		<td colspan="2" class ="header_tbl" style = "font-size:22px; height:40px;"  align = "left">
			　予備品管理システム (<%=formBean.kojou%>)　　　
			<span style="font-size:30px; text-shadow:2px 2px #666; 	color:#aaa;">修理・貸出返却登録画面</span>
		</td>
	</tr>
	<!--HEADER TITLE END -->
	

	<!--メインメニュー画面　START  -->
	<tr style="height:628px; ">

		<td class="right" >
			 <!--<div class="mainLine" id = "mainLine" style="display:inline; " ></div>  -->

			<table  width ="100%"  class="mainTbl_Right" >
				<!--発注 -->
				<tr>
					<td id="" align = "left"   class="selTitle">　Y品番:　&nbsp;&nbsp;
					<input type="text"  class="" name="itemNo1" id="itemNo1" style="width: 50px; height:25px; font-size:15px; color:blue;  background-color:#CCC;"  value="<%=formBean.getItemNo1() %>" readonly> -
					<input type="text"  class="" name="itemNo2" id="itemNo2" style="width: 50px; height:25px; font-size:15px; color:blue;  background-color:#CCC;" value="<%=formBean.getItemNo2() %>"  readonly>
				</tr>
				<tr>
					<td id="" align = "left"  valign="top"  class="selTitle" colspan="3">　品名:　　
						<textarea name="" cols="40" rows="2" style="width:  510px; font-size:15px; color:blue; background-color:#CCC;" readonly  ><%=formBean.getItemNm() %></textarea>
					</td>
				</tr>
                <tr>
					<td id="" align = "left"  valign="top"  class="selTitle" colspan="3">　型式:　　
						<textarea name="" cols="40" rows="2" style="width:  510px; font-size:15px; color:blue; background-color:#CCC;"  readonly ><%=formBean.getModel() %></textarea>
					</td>
				</tr>

			     <tr>
					<td id="" align = "left"  valign="top"  class="selTitle" colspan="3">　理由:　　
						<textarea name="" cols="40" rows="2" style="width:  510px; font-size:15px; color:blue; background-color:#CCC;"  readonly ><%=formBean.getDelvReason() %></textarea>
					</td>
				</tr>
				
				<tr>
					<td id="" align = "left"  valign="middle"  class="selTitle">　棚番:　　
					<input type="text"  class="" name="cc" id="cc" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getRackNo()%>">
					　　　　　　　　出庫区分:　
					<input type="text"  class="" name="cc" id="cc" style="width: 150px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly value="<%=formBean.getDelvDiv()%>">
					</td>
				</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td> </td></tr>



				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2"><hr>　修理/貸出担当者:
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getDelvUsrKumi()%>">
						<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getDelvUsr()%>">
					</td>
				</tr>


				<tr>
					<td id="" align = "left"   class="selTitle" colspan="2">　&nbsp;返却チェック者:
						<select name="odrUsr"  id="odrUsr"  style="width:120px; height:30px; font-size:15px; color:blue;" onChange="odrUsrSideDell(this);">
								<option value=''></option>
								<%
								Ren3000Bean.PullData[] inputEmpPullList = formBean.getInputEmpPullList();
								for (int i = 0; inputEmpPullList != null && i < inputEmpPullList.length; i++) {
									Ren3000Bean.PullData data = inputEmpPullList[i];
								%>
								<option value='<%=data.key%>' <%=data.selected%> ><%=data.value%></option>
								<%}%>
						</select>
						<select name="usrList"  id="usrList"  style="width:120px; height:30px; font-size:15px; color:blue;" onChange="odrUsrSideDell2(this);">
								<option value=''></option>
								<%
								Ren3000Bean.PullData[] inputEmpPullList2 = formBean.getInputEmpPullList2();
								for (int i = 0; inputEmpPullList2 != null && i < inputEmpPullList2.length; i++) {
									Ren3000Bean.PullData data = inputEmpPullList2[i];
								%>
								<option value='<%=data.key + "*" + data.key2%>' <%=data.selected%> ><%=data.value%></option>
								<%}%>
						</select>　　　　　　　
<%if("1".equals(formBean.viewFlg)){%>
						<input type="button"  onclick="cancelBtn();" class="orderBtn"  value="出庫取消">　　　
<%}else{ %>
　　　　　　　　　　　
<%} %>
						<input type="button"  onclick="orderBtn();" class="orderBtn"  value="返却登録">　　
						<input type="button"  onclick="backBtn();" class="backBtn"  value="戻る">　
					</td>
				</tr>

			</table>




			<!-- 出庫 -->
			<div class="warehouse">
			<table border="1"  style="border-color: #CCCCCF;">

				<tr>
					<td id="" align = "left"  valign="middle" class="selTitle" ><br>
					【出庫】　出庫日:　<input type="text"  class="" name="delvDt" id="delvDt" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getDelvDt()%>"">
					        　出庫先:　<input type="text"  class="" name="" id="" style="width: 100px; height:25px; font-size:15px; color:blue; background-color:#CCC;" readonly  value="<%=formBean.getDelvSite()%>">
					　　 新品数量:　	<input type="text"  class="" name="delvNewNum" id="delvNewNum" style="width: 60px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getDelvNewNum()%>">
					　中古数量:　	<input type="text"  class="" name="delvUsedNum" id="delvUsedNum" style="width: 60px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getDelvUsedNum()%>">
					</td>
				</tr>
				
				<tr>
					<td id="" align = "left"  valign="middle" class="selTitle" ><br>【返却】　返却日:&nbsp;&nbsp;
						<input type="date"  class="" name="retDt" id="retDt" style="width: 100px; height:26px; font-size:15px; color:blue;"  value="<%=formBean.getRetDt()%>">
						　返却数/出庫数:　<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" value="<%=formBean.getRetTotalNum() %>/<%=formBean.getDelvTotalNum() %>"  readonly >
					</td>
				</tr>
				
				<tr>
					<td><br>　　　　【在庫に反映】　返却先:　
						<select id="retSite"  name="retSite" style="width:150px; height:29px; font-size:15px; color:blue;" onChange="">
								<option value=''></option>
								<%
								Ren3000Bean.PullData[] inputRetSiteList = formBean.getInputRetSiteList();
								for (int i = 0; inputRetSiteList != null && i < inputRetSiteList.length; i++) {
									Ren3000Bean.PullData data = inputRetSiteList[i];
								%>
								<option value='<%=data.key%>' <%=data.selected%> ><%=data.value%></option>
								<%}%>
						</select>
						　新品数量:　
						<input type="text"  class="" name="retNewNum" id="retNewNum" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right;"  onclick='clsNKB.setNumKeyBoard(this, 5, 0, true, 200);' onChange='afterInputData(this);' readonly value="" >
						<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getRetNewNum()%>">
						　中古数量:　
						<input type="text"  class="" name="retUsedNum" id="retUsedNum" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right;"  onclick='clsNKB.setNumKeyBoard(this, 5, 0, true, 200);' onChange='afterInputData(this);' readonly  value="">
						<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getRetUsedNum()%>">
					</td>
				</tr>
				
				<tr>
					<td>　　　　【在庫に未反映】廃棄先:　
						<select name="scrSite"  id="scrSite"  style="width:150px; height:29px; font-size:15px; color:blue;" onChange="">
								<option value=''></option>
								<%
								Ren3000Bean.PullData[] inputScrSiteList = formBean.getInputScrSiteList();
								for (int i = 0; inputScrSiteList != null && i < inputScrSiteList.length; i++) {
									Ren3000Bean.PullData data = inputScrSiteList[i];
								%>
								<option value='<%=data.key%>' <%=data.selected%> ><%=data.value%></option>
								<%}%>
						</select>
						　新品数量:　
						<input type="text"  class="" name="scrNewNum" id="scrNewNum" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right;"onclick='clsNKB.setNumKeyBoard(this, 5, 0, true, 200);' onChange='afterInputData(this);' readonly  value="">
						<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getScrNewNum()%>">
						　中古数量:　
						<input type="text"  class="" name="scrUsedNum" id="scrUsedNum" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right;" onclick='clsNKB.setNumKeyBoard(this, 5, 0, true, 200);' onChange='afterInputData(this);' readonly  value="">
						<input type="text"  class="" name="" id="" style="width: 50px; height:25px; font-size:15px; color:blue; text-align:right; background-color:#CCC;" readonly  value="<%=formBean.getScrUsedNum()%>">
						<br>
					</td>
				</tr>
			</table>
			</div>



			<!--ログインMAIN画面　END  -->

		</td>
	</tr>
</table>
	<div class='footer' align='right' style="font-size:35px; background-image: url(../../common/img/toyotaB.png); background-repeat: no-repeat; align:top;" ></div>
    <div class='ImageZone' align='right' style="font-size:20px; align:top"><img  class="image"  src='<%=appMng.getAppConfig("userconfig.imagepath")%><%=formBean.getPicfileNm()%>' height='237px' width='330px'></div>
	<div id="NumKeyBoardID"></div>

	<!--警告 ポップアップ---------------------------------------------------------------------------- -->
	<div id="allbackgr" class="allbackgr" style="display:none;"></div>
	<div class="opAlertBtn" id = "opAlertBtn" style="display:none;" ></div>
	<div class="opAlertButton" id = "opAlertButton" style="display:none;" ></div>
	<div class="opAlertTop" id = "opAlertTop" style="display:none; font-size:22px;">　予備品管理システム　</div>
	<div class="opAlert" id = "opAlert" style="display:none;"></div>
	<!-- -------------------------------------------------------------------------------------------- -->


	<div class='rePayTitle1'></div>
	<div class='rePayTitle2'></div>
	
	<input type="hidden" id="nextPage" name="nextPage" value="">
	<input type="hidden" id="usrListKey" name="usrListKey" value="">
	<input type="hidden" id="orderExe" name="orderExe" value="">
	<input type="hidden" id="retSiteKey" name="retSiteKey" value="">
	<input type="hidden" id="scrSiteKey" name="scrSiteKey" value="">
	<input type="hidden" id="updateDt" name="updateDt" value="<%=formBean.getUpdateDt()%>">
	<input type="hidden" id="delvNo" name="delvNo" value="<%=formBean.getDelvNo()%>">
</form>
</body>
</html>
